//
//  LGReviseIntroduceController.m
//  BreathTrainingTool
//
//  Created by 1234 on 2024/5/21.
//  修改简介

#import "LGReviseIntroduceController.h"

#import "LGCustomTextView.h"

@interface LGReviseIntroduceController ()<LGTextViewDelegate>
/**   */
@property (nonatomic , strong)LGCustomTextView *contentTF;
/**   */
@property (nonatomic , strong)UIButton *saveBtn;

@end

@implementation LGReviseIntroduceController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"修改简介";
    [self createSubView];
    self.contentTF.content = self.content;
}

//完成
-(void)saveButtonAction{
    if (self.contentTF.content.length>0) {
        [RequestUtil bodayPOST:@"/patient/updateDoctorDesc" parameters:@{@"describtion":self.contentTF.content,@"id":kUserId} header:YES success:^(NSInteger code, NSString *message, id returnData) {
            if (code == 200) {
                [TooltipView showMessage:@"保存成功" offset:0];
                [self.navigationController popViewControllerAnimated:YES];
            }else{
                [TooltipView showMessage:message offset:0];
            }
        } error:^(NSError *error) {
            
        }];
        
    }else{
        [TooltipView showMessage:@"请输入简介内容" offset:0];
    }
}


-(void)textViewHeightChanged:(CGFloat)height{
    CGFloat contentH = height>viewPix(213)?height:viewPix(213);
    self.contentTF.frame = CGRectMake(viewPix(16), viewPix(60), Screen_W-viewPix(32), height);
}


-(void)createSubView{
    self.view.backgroundColor = [UIColor whiteColor];
    
    UILabel *titleLabel = [UILabel lableWithText:@"请输您的简介" colorString:@"#282828" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    titleLabel.frame = CGRectMake(viewPix(16), viewPix(24), Screen_W-viewPix(32), viewPix(24));
    [self.view addSubview:titleLabel];
    [self.view addSubview:self.contentTF];
    
    self.saveBtn = [UIButton buttonWithTitle:@"完成" topMargin:Screen_H-topBarHeight-viewPix(88)];
    [self.saveBtn addTarget:self action:@selector(saveButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.saveBtn];
}

-(LGCustomTextView *)contentTF{
    if(!_contentTF){
        _contentTF = [LGCustomTextView textViewWithPlaceHolder:@"请输入" textColor:@"#282828" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft keyboard:UIKeyboardTypeDefault];
        _contentTF.frame = CGRectMake(viewPix(16), viewPix(60), Screen_W-viewPix(32), viewPix(213));
        _contentTF.backgroundColor = [UIColor colorWithString:@"#F2F1F8"];
        _contentTF.cornerRidus = 20;
        _contentTF.textContainerInset = UIEdgeInsetsMake(16, 16, 16, 16);
    }
    return _contentTF;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
